package buffer;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

public class FileIOTest {
	public static void main(String[] args) throws IOException {
		/*FileOutputStream fos = new FileOutputStream("a.txt");
		FileChannel fc = fos.getChannel();
		ByteBuffer bb = ByteBuffer.allocate(11);
		bb.put("hello world".getBytes());
		bb.flip();
		fc.write(bb);
		fos.close();*/
		FileInputStream fis = new FileInputStream("a.txt");
		FileChannel fc = fis.getChannel();
		ByteBuffer bb = ByteBuffer.allocate(fis.available());
		fc.read(bb);
		System.out.println(new String(bb.array()));
	}
}
